package com.itheima.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo03 {

    public static void main(String[] args) {

        Collection<String> collection=new ArrayList<>();
        collection.add("蔡徐坤");
        collection.add("鹿晗");
        collection.add("鹿晗");
        collection.add("张艺兴");
        collection.add("黄子韬");
        collection.add("吴签");

      /*  for (int i = collection.size() - 1; i >= 0; i--) {
            String s = collection.get(i);
            if(s.equals("鹿晗")){
                collection.remove(i);
            }
        }*/
        Iterator<String> iterator = collection.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            if(next.equals("鹿晗")){
               // collection.add("鹿晗");
                iterator.remove();
            }
        }
        System.out.println(collection);

    }
}
